home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Newbie: How to return Multi-Dimensional Array's?
- Date: 07 Feb 1996 16:31:57 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb7093157@qcd.lanl.gov>
- References: <4f7t4m$4bk@news.xs4all.nl>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: maris@xs4all.nl's message of Wed, 07 Feb 1996 00:47:38 GMT
-
- In article <4f7t4m$4bk@news.xs4all.nl> maris@xs4all.nl (Anthony
- Moendir) writes:
- <snip>
- How can you return Multi-Dimensional Array's from a function?
- I would like to do something like this:
-
-
- Declare your function first.
-
- char (*foo(void))[5];
-
- voidt main()
- ^^^^^
-
- Make that int main(void)
-
- {
-
- declare tmp as char (*tmp)[5];
-
- char arr[10][5];
-
- Don't declare things you don't need.
-
- tmp=foo();
-
- Do anything you like with tmp, e.g. print tmp[2][3].
-
- Add a return 0.
-
- }
-
- char *foo()
-
- Change that to char (*foo(void)) [5]
-
- {
- char arr[10][5];
-
- Add static to the declaration.
-
- // do something
-
- Write C or post to comp.lang.c++
-
- return (arr)
- }
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-